/*    */ package blockbuster.components.rate;
/*    */ 
/*    */ import blockbuster.components.BedrockComponentBase;
/*    */ import blockbuster.components.IComponentEmitterUpdate;
/*    */ import blockbuster.emitter.BedrockEmitter;
/*    */ import blockbuster.math.Constant;
/*    */ import blockbuster.math.IValue;
/*    */ import blockbuster.math.Operation;
/*    */ import blockbuster.math.molang.MolangException;
/*    */ import blockbuster.math.molang.MolangParser;
/*    */ import blockbuster.math.molang.expressions.MolangExpression;
/*    */ import blockbuster.math.molang.expressions.MolangValue;
/*    */ import com.google.gson.JsonElement;
/*    */ import com.google.gson.JsonObject;
/*    */ 
/*    */ public class BedrockComponentRateInstant extends BedrockComponentRate implements IComponentEmitterUpdate {
/* 17 */   public static final MolangExpression DEFAULT_PARTICLES = (MolangExpression)new MolangValue(null, (IValue)new Constant(10.0D));
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public BedrockComponentBase fromJson(JsonElement elem, MolangParser parser) throws MolangException {
/* 26 */     if (!elem.isJsonObject()) return super.fromJson(elem, parser);
/*    */     
/* 28 */     JsonObject element = elem.getAsJsonObject();
/*    */     
/* 30 */     if (element.has("num_particles"))
/*    */     {
/* 32 */       this.particles = parser.parseJson(element.get("num_particles"));
/*    */     }
/*    */     
/* 35 */     return super.fromJson((JsonElement)element, parser);
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public JsonElement toJson() {
/* 41 */     JsonObject object = new JsonObject();
/*    */     
/* 43 */     if (!MolangExpression.isConstant(this.particles, 10.0D))
/*    */     {
/* 45 */       object.add("num_particles", this.particles.toJson());
/*    */     }
/*    */     
/* 48 */     return (JsonElement)object;
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public void update(BedrockEmitter emitter) {
/* 54 */     double age = emitter.getAge();
/*    */     
/* 56 */     if (emitter.playing && Operation.equals(age, 0.0D)) {
/*    */       
/* 58 */       emitter.setEmitterVariables(0.0F);
/*    */       
/* 60 */       for (int i = 0, c = (int)this.particles.get(); i < c; i++)
/*    */       {
/* 62 */         emitter.spawnParticle();
/*    */       }
/*    */     } 
/*    */   }
/*    */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\blockbuster\components\rate\BedrockComponentRateInstant.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */